#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int nums[] = { -1,0,3,5,9,12 };
	int target = 5;
	int nums_size = sizeof(nums) / sizeof(nums[0]);
	int i = nums_size / 2;
	int front = 0;
	int rear = nums_size - 1;
	while (nums[i] != target) {
		if (nums[i] >= target) {//target<=nums[i]
			rear = i;
			i = (front + rear) / 2;
		}
		else {//target>nums[i]

			front = i;
			i = (front + rear) / 2;
		}
	}
	cout << i << endl;

	return 0;
}
